package com.unity3d.app5;

import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;


public class BlankFragment extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        //获取控件方法一
        View view =inflater.inflate(R.layout.fragment_blank,container,false);
        TextView textView = view.findViewById(R.id.fragment1_text1);
        textView.setText("华子啊🐂");
        return view;
        // Inflate the layout for this fragment

    }

    //获取控件方法二
    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        //拿到控件引用
        TextView textView=getActivity().findViewById(R.id.fragment1_text1);
        textView.setText("华子🐂哇");
        textView.setOnClickListener(
                (view)->{
                    Log.i("hello","hello world");

                    //TODO 跳转activity
                    Intent intent=new Intent(getActivity(),MainActivity2.class);
                    startActivity(intent);
                }
        );
    }
}